// 工资设置

const defaultSetting = {
  baseSalary: 0,
  overtimeSalary: 0
}

export default {
  key: 'kuan-overtime-setting',
  get() {
    try {
      const setting = localStorage.getItem(this.key)
      return setting ? JSON.parse(setting) : defaultSetting
    } catch (e) {
      localStorage.setItem(this.key, JSON.stringify(defaultSetting))
      return defaultSetting
    }
  },
  set(data) {
    const oldSetting = this.get()
    localStorage.setItem(this.key, JSON.stringify({ ...oldSetting, ...data }))
  },
  clear() {
    localStorage.removeItem(this.key)
  }
}
